package com.ruoyi.bom.controller;

import com.ruoyi.bom.domain.TqlHllShop;
import com.ruoyi.bom.service.TqlHllShopService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 部门信息
 *
 * @author ruoyi
 */
@RestController
@Api(tags = "部门信息管理")
@RequestMapping("/shop")
public class TqlHllShopController extends BaseController  {

    @Autowired
    private TqlHllShopService tqlHllShopService;

    @ApiImplicitParams({
        @ApiImplicitParam(name = "date", value  = "日期", paramType = "query", dataType = "string"),
        @ApiImplicitParam(name = "createBy", value = "操作人", paramType = "query", dataType = "string")
    })
    @ApiOperation("门店列表")
    @GetMapping("/find")
    public TableDataInfo list(@ApiIgnore @RequestParam Map<String, String> params) {
        startPage();
        List<TqlHllShop> list = tqlHllShopService.selectShopList(params);
        return getDataTable(list);
    }

    @ApiOperation("获取全部店铺")
    @GetMapping("/findAll")
    public List<TqlHllShop>  findAll(String shopName) {
       // startPage();
        HashMap<String,String> map=new HashMap<>();
        map.put("shopName",shopName);
        List<TqlHllShop> list =tqlHllShopService.selectShopList(map);
        return list;
//        List<TqlHllShop> list = tqlHllShopService.selectShopListAll();
//        return getDataTable(list);
    }

    @ApiOperation("开通店铺")
    @GetMapping(value = "/open")
    @RequiresPermissions("bom:shop:open")
    public AjaxResult open(@RequestParam("id") Long id, @RequestParam("shopCode") Long shopCode) {
        return success(tqlHllShopService.open(id, shopCode));
    }


    @ApiOperation("同步店铺")
    @GetMapping(value = "/sync")
    @RequiresPermissions("bom:shop:sync")
    public AjaxResult sync(@RequestParam("deptCode") String deptCode) {
        return success(tqlHllShopService.sync(deptCode));
    }
}
